#include "HistoryManage.h"




CHistoryManage :: CHistoryManage()
{
    m_historyrecord = NULL;
    m_historyfileheader = NULL;
    m_historyfilename.clear();
}


CHistoryManage :: ~CHistoryManage()
{
    if(m_historyrecord != NULL)
       delete m_historyrecord;
    if(m_historyfileheader != NULL)
       free(m_historyfileheader);
}


int CHistoryManage :: HistoryManageInit(string filename)
{
    m_historyfilename = filename;
    if(NULL ==  m_historyrecord)
    {
       m_historyrecord = new CHistoryRecord();
       m_historyfileheader = m_historyrecord->HistoryInit(filename.c_str());
    }
    return 0;        
}


int CHistoryManage :: HistoryManageUnInit()
{ 
    if(m_historyrecord != NULL)
       delete m_historyrecord;
    return 0;
}


int CHistoryManage :: HistoryManageAdd(char *data, int datalen)
{
    if(m_historyrecord != NULL)
    {
       m_historyrecord->HistoryAdd(data, datalen);
    }
    return 0;
}

int CHistoryManage :: HistoryManageSetValid(char valid, int writeindex)
{
    if(m_historyrecord != NULL)
    {
       m_historyrecord->HistorySetValid(valid, writeindex);
    }
    return 0;
}


int CHistoryManage :: HistortManageGetRecord(char *data)
{
    if(NULL == data)
    {
      m_historyrecord->HistoryRead(data);  
      return -1;
    }
    return 0;
}